package com.ktg.mes.pro.domain;

import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ktg.mes.md.domain.MdItem;
import com.ktg.mes.util.LeftJoin;
import lombok.Data;
import lombok.experimental.Accessors;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;

/**
 * 生产任务对象 pro_task
 *
 * @author yinjinlu
 * @date 2022-05-15
 */
@Data
@Accessors(chain = true)
@TableName("pro_task")
public class ProTask extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 任务ID */
    @TableId(value = "task_id", type = IdType.AUTO)
    @JsonFormat(shape = JsonFormat.Shape.STRING) //转化成string传到前端
    private Long taskId;

    /** 任务编号 */
    @Excel(name = "任务编号")
    private String taskCode;

    /** 任务名称 */
    @Excel(name = "任务名称")
    private String taskName;

    /** 生产工单ID */
    @Excel(name = "生产工单ID")
    @LeftJoin(leftTable = "pro_workorder",leftTableColumn = "workorder_id",selectColumn = ProWorkorder.mainSelectColumnNotId)
    private Long workorderId;

    /** 生产工单编号 */
    @Excel(name = "生产工单编号")
    private String workorderCode;

    /** 工单名称 */
    @Excel(name = "工单名称")
    private String workorderName;

    /** 工作站ID */
    @Excel(name = "工作站ID")
    private Long workstationId;

    /** 工作站编号 */
    @Excel(name = "工作站编号")
    private String workstationCode;

    /** 工作站名称 */
    @Excel(name = "工作站名称")
    private String workstationName;

    /** 工序ID */
    @Excel(name = "工序ID")
    private Long processId;

    /** 工序编码 */
    @Excel(name = "工序编码")
    private String processCode;

    /** 工序名称 */
    @Excel(name = "工序名称")
    private String processName;

    /** 产品物料ID */
    @Excel(name = "产品物料ID")
    @LeftJoin(leftTable = "md_item",leftTableColumn = "item_id",selectColumn = MdItem.mainSelectColumnAppearance)
    private Long itemId;

    /** 产品物料编码 */
    @Excel(name = "产品物料编码")
    private String itemCode;

    /** 产品物料名称 */
    @Excel(name = "产品物料名称")
    private String itemName;

    /** 规格型号 */
    @Excel(name = "规格型号")
    private String specification;

    /** 单位 */
    @Excel(name = "单位")
    private String unitOfMeasure;

    /** 排产数量 */
    @Excel(name = "排产数量")
    private BigDecimal quantity;

    @TableField(exist = false)
    private String tag;

    /** 剩余入库数量 */
    @Excel(name = "剩余入库数量")
    private BigDecimal quantityNotIn;

    private BigDecimal quantityQuanlify;

    private BigDecimal quantityUnquanlify;

    /** 调整数量 */
    @Excel(name = "调整数量")
    private BigDecimal quantityChanged;

    /** 客户ID */
    @Excel(name = "客户ID")
    private Long clientId;

    /** 客户编码 */
    @Excel(name = "客户编码")
    private String clientCode;

    /** 客户名称 */
    @Excel(name = "客户名称")
    private String clientName;

    /** 客户简称 */
    @Excel(name = "客户简称")
    private String clientNick;



    /** 开始生产时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "开始生产时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date startTime;

    /** 生产时长 */
    @Excel(name = "生产时长")
    private Long duration;

    /** 完成生产时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "完成生产时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    /** 甘特图显示颜色 */
    @Excel(name = "甘特图显示颜色")
    private String colorCode;

    /** 需求日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "需求日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date requestDate;

    /** 是否生产领料 */
    private String isGetMaterials;
    private String status;

    /** 排产日期 */
    private String month;

    /** 时间段(上午，下午，通宵) */
    private String timeSlot;


    /** 设备id */
    private Long machineryId;


    /** 排产日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date productionDate;

    /** 在库数量 */
    @TableField(exist = false)
    private Long quantityOnhand;

    /** 预留字段1 */
    private String attr1;

    /** 预留字段2 */
    private String attr2;

    /** 预留字段3 */
    private Long attr3;

    /** 预留字段4 */
    private Long attr4;

    /** 粘度 */
    private String viscosity;

    /**批号 */
    private String batchNo;


    /** 工艺路线ID */
    @LeftJoin(leftTable = "pro_route",leftTableColumn = "route_id",selectColumn = ProRoute.mainSelectColumn)
    private Long routeId;

    @TableField(exist = false)
    private String endDate;

    @TableField(exist = false)
    private String startDate;

    /** 销售订单Id */
    @Excel(name = "销售订单Id")
    private String scaleId;

    /** 是否完成 */
    private String isFinish;

    /** 是否单表拖动，单表拖动需要判断是否删除排产任务 */
    @TableField(exist = false)
    private String isDelete;

    @TableField(exist = false)
    private Integer orderNum;

    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "标签日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date tagDate;

    @TableField(exist = false)
    private String bucketCode;

    //排产状态
    @Excel(name = "排产状态")
    private String taskStatus;


    public final static String taskStatusFinish = "完工";
    public final static String taskStatusDefect = "报废";
    public final static String taskStatusInWarehouse = "已入库";

    public final static String taskStatusAllInWarehouse = "全部入库";
    public final static String taskStatusUnqualified = "不合格";
    public final static String taskStatusConcessionAcceptance = "让步接收";




}
